package org.penguin.study.bk.config

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.core.env.Environment
import org.springframework.core.env.get
import org.springframework.jdbc.datasource.DriverManagerDataSource
import javax.sql.DataSource

@Configuration
class SimpleDataSourceConfig {

    @Autowired
    lateinit var env: Environment

    @Bean
    fun dataSource(): DataSource {
        return DriverManagerDataSource(
            env["spring.datasource.url"]!!,
            env["spring.datasource.username"]!!,
            env["spring.datasource.password"]!!
        )
    }
}